package com.canton.controller;

import com.canton.dao.entity.CommonResult;
import com.canton.dao.entity.EchartsData;
import com.canton.dao.entity.ResponseCode;
import com.canton.service.KBQAService;
import com.canton.service.KnowledgeSearchService;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author: wujunchao
 * @date: 202-12-04 19:58
 */
@Controller
@RequestMapping(value = "/kbqa", produces="application/json;charset=utf-8")
@CrossOrigin//允许跨域访问
public class KBQAController {
    @Autowired
    private KBQAService kbqaService;

    @PostMapping("/getQuestion")
    @ApiOperation(value="知识问答", notes="传入Question")
    @ResponseBody
    public CommonResult getQuestion(@RequestParam("question") String question) {
        String answer = kbqaService.getQuestion(question);
        if(StringUtils.isNotBlank(answer)){
            return CommonResult.success(answer);
        }else{
            return CommonResult.failure(ResponseCode.ERROR_500,"未知错误！");
        }

    }
}
